home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctjjl86.arc / BYTFRNGE.ASM < prev    next >
Assembly Source File  |  1986-04-17  |  6KB  |  172 lines

  1. ; *** Listing 10 ***
  2. ;
  3. ;This program benchmarks the byte-move driver with automatic
  4. ; erasure by a blank fringe.
  5. ;Link the byte-move form_driver/erase_form_driver
  6. ; module to this program.
  7. ;
  8. stack    segment para stack 'STACK'
  9.     db    512 dup(0)
  10. stack    ends
  11. ;
  12. one    segment para public 'CODE'
  13.     assume    cs:one,ds:one,es:nothing
  14.     extrn    form_driver:near
  15. ;
  16. iteration_count  dw    0   ;will hold # of times to move the objects
  17. ;
  18. ;Lists describing image, location, and motion of 8 objects.
  19. ;
  20. ;pointers to form byte strings for each object:
  21. form_address     dw  f0, f1, f2, f3, f3, f2, f1, f0 
  22.                             
  23. ;the index for the last object in these lists:
  24. highest_object_pointer equ (($-form_address)-2)
  25.  
  26. row         dw 100,100,100,100,100,100,100,100 ;lines (0 - 198)
  27. column         dw  32, 32, 32, 32, 32, 32, 32, 32 ;bytes (0 - 79)
  28. row_increment     dw  -2,  2,  0, -2,  0,  0, -2,  2 ;lines (0 - 198)
  29. column_increment dw   1,  1,  0, -1,  1, -1,  0, -1 ;bytes (0 - 79)
  30. left_margin     dw   0,  0,  0,  0,  0,  0,  0,  0 ;byte # 0-79)
  31. right_margin     dw  74, 72, 70, 68, 68, 70, 72, 74 ;byte # (0-79)
  32. top_margin     dw   0,  0,  0,  0,  0,  0,  0,  0 ;line # (0 - 198)
  33. bottom_margin     dw 190,180,170,160,160,170,180,190 ;line # (0 - 198)
  34. ;                            
  35. ;Form byte structures, as follows:
  36. ;    byte 1: # of scan lines in forms.
  37. ;    byte 2: # of bytes per scan line of form.
  38. ;    byte 3: first byte of image, followed by rest of bytes forming
  39. ;        image, with bytes for top scan line, left to right, 
  40. ;        first, second scan line next, and so on.
  41. ;
  42. f0    db    10,6
  43.     db    2 dup(6 dup(000h))
  44.     db    000h,0f0h,00fh,0f0h,00fh,000h
  45.     db    000h,0f0h,03fh,0fch,00fh,000h
  46.     db    000h,0ffh,0ffh,0ffh,0ffh,000h
  47.     db    000h,0f0h,0ffh,0ffh,00fh,000h
  48.     db    000h,0f0h,03fh,0fch,00fh,000h
  49.     db    000h,0f0h,00fh,0f0h,00fh,000h
  50.     db    2 dup(6 dup(000h))
  51. f1    db    20,8
  52.     db    2 dup(8 dup(000h))
  53.     db    4 dup(000h,6 dup(055h),000h)
  54.     db    4 dup(000h,6 dup(0ffh),000h)
  55.     db    4 dup(000h,6 dup(0aah),000h)
  56.     db    4 dup(000h,6 dup(055h),000h)
  57.     db    2 dup(8 dup(000h))
  58. f2    db    30,10
  59.     db    2 dup(10 dup(000h))
  60.     db  26 dup(000h,0ffh,0aah,0aah,055h,055h,0aah,0aah,0ffh,000h)
  61.     db    2 dup(10 dup(000h))
  62. f3    db    40,12
  63.     db    2 dup(12 dup(000h))
  64.     db    9 dup(000h,10 dup(0ffh),000h)
  65.     db    3 dup(000h,0ffh,0ffh,6 dup(0aah),0ffh,0ffh,000h)
  66.       db  3 dup(000h,0ffh,0ffh,0aah,4 dup(055h),0aah,0ffh,0ffh,000h)
  67.       db  6 dup(000h,0ffh,0ffh,0aah,055h,0,0,055h,0aah,0ffh,0ffh,000h)
  68.       db  3 dup(000h,0ffh,0ffh,0aah,4 dup(055h),0aah,0ffh,0ffh,000h)
  69.       db  3 dup(000h,0ffh,0ffh,6 dup(0aah),0ffh,0ffh,000h)
  70.       db  9 dup(000h,10 dup(0ffh),000h)
  71.       db  2 dup(12 dup(000h))
  72. ;
  73. start    proc    far
  74.     push    ds          ;set up for return to DOS
  75.     sub    ax,ax          ; through the instruction at DS:0 set
  76.     push    ax          ; up by DOS when it loads this program
  77.     cld              ;the form driver counts up
  78.     push    cs
  79.     pop    ds          ;DS and CS are to be the same
  80.     mov    ax,0b800h     ;ES is to point to Color Graphics
  81.     mov    es,ax          ; Adapter's memory buffer
  82.     mov    ax,0004h      ;set 320x200 color mode
  83.     int    10h          ;
  84. ;
  85. ;Set number of times to move objects
  86. ;
  87. ;number of times to repeat move loop:
  88.     mov    [iteration_count],700    
  89. ;
  90. ;For each iteration, move each object in turn by moving
  91. ; it one increment and drawing it at the new position.
  92. ;
  93. next_iteration:
  94.     mov    si,highest_object_pointer   ;start at last object
  95. ;
  96. ;Move each object in turn.
  97. ;
  98. move_next_object:
  99. ;
  100. ;Advance the object's row and column and adjust increments
  101. ; so the object remains within its boundaries.
  102. ;
  103. ;If adding the row increment to the row would place it outside
  104. ; its margins...
  105. ;
  106.     mov    ax,[si+row]           ;test the new line position
  107.     add    ax,[si+row_increment]  ; to see if it goes outside
  108.     cmp    ax,[si+top_margin]     ; its limit
  109.     jb    negate_row_increment   ;if outside negate the 
  110.     cmp    ax,[si+bottom_margin]  ; increment so that it will 
  111.     jbe    test_column_increment  ; move towards its other limit
  112. ;
  113. ;...then make the row increment negative if positive and
  114. ; positive if negative.
  115. ;
  116. negate_row_increment:
  117.     neg    [si+row_increment]   ;make it move in other direction
  118. ;
  119. ;If adding the column increment to the column would place it
  120. ; outside its margins...
  121. ;
  122. test_column_increment:
  123.     mov    ax,[si+column]         ;if the column for the object
  124.     add    ax,[si+column_increment] ; would go outside its left 
  125.     cmp    ax,[si+left_margin]     ; or right limits, then 
  126.     jb    negate_column_increment  ; negate its increment so 
  127.     cmp    ax,[si+right_margin]     ; that it will move in the 
  128.     jbe    add_increments         ; opposite direction
  129. ;
  130. ;...then make the column increment negative if positive and
  131. ; positive if negative.
  132. ;
  133. negate_column_increment:
  134.     neg    [si+column_increment]  ;set to move in opp. direction
  135. ;
  136. ;Add the increments to the row and column to arrive at the
  137. ; object's next position.
  138. ;
  139. add_increments:
  140.     mov    ax,[si+row_increment]     ;calc the next line postion
  141.     add    [si+row],ax         ; and store it
  142.     mov    ax,[si+column_increment] ;calc the next column postion
  143.     add    [si+column],ax         ; and store it
  144. ;
  145. ;Draw the object at the new location.
  146. ;
  147.     push    si              ;save this object index
  148.     mov    bx,[si+row]          ;find line and column # at
  149.     mov    cx,[si+column]          ; which to place the object
  150.     mov    si,[si+form_address]  ;find the addr. of object's form
  151.     call    form_driver          ;put object's image into screen
  152.     pop    si              ;restore the object index
  153. ;
  154.     sub    si,2              ;point to next object to move
  155.     jns    move_next_object      ; if not done jmp to move it
  156. ;
  157.     dec    [iteration_count]     ;count down number of times to
  158.     jnz    next_iteration          ; move all the objects
  159. ;
  160. ;Reset the mode to 80x25 color text mode.
  161. ;
  162.     mov    ax,0003h          ;before returning to DOS,
  163.     int    10h              ; set screen to 80x25 text mode
  164. ;
  165. ;Return to DOS.
  166. ;
  167.     ret                  ;return though instruction at
  168.                       ; start of PSP set up by DOS
  169. start    endp
  170. one    ends
  171.     end    start
  172.